package com.ysb.searchserver;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;

public class SpringContextUtil {
	
	private static ApplicationContext applicationContext; // Spring应用上下文环境


	public static void setApplicationContext(ApplicationContext context) {
		applicationContext = context;
	}


	@SuppressWarnings("unchecked")
	public static <T> T getBean(String name) throws BeansException {
		return (T) applicationContext.getBean(name);
	}
}
